package com.azdebugit.suanfa.test.duilie;

import java.util.Stack;

public class Solution {
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();
    
    public void push(int node) {
        stack1.push(node);
    }
    
    public int pop() {
        int result = 0;
    	if(stack1.isEmpty()&&stack2.isEmpty()) {
    		throw new RuntimeException("没有可以出队的元素");
    	}
    	if(stack2.isEmpty()) {
    	    while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
    	}
    	if(!stack2.isEmpty()){
    		result = stack2.pop();
    	}
    	return result;
    }
    public static void main(String[] args) {
        Solution test = new Solution();
        test.stack1.push(1);
        test.stack1.push(2);
        test.stack1.push(3);
        while(test.stack1.size()>0){
            System.out.println(test.stack1.pop());
        }
    }
}
